Open
Conversation
Go implementation of the x402 payment client, mirroring the TypeScript
and Python packages.
- EVMSigner + SignEVMPayment — EIP-3009 TransferWithAuthorization
signing for Base/SKALE (uses go-ethereum's apitypes.TypedData +
crypto.Sign with canonical V=27/28)
- SolanaSigner + SignSolanaPayment — SPL TransferChecked with optional
ComputeBudget instructions; signs, submits via JSON-RPC, and returns
the on-chain signature in the X-Payment envelope
- Handler — unified NewHandler(HandlerOptions{Network, EVMSigner,
SolanaSigner, RPCURL, HTTPClient}) factory with Sign / Headers
methods and network-based requirement selection
- PaymentRequirementFromMap — helper that adapts a raw 402 'accepts'
entry (map[string]any) into the typed struct
- Module: github.com/AceDataCloud/X402Client/go, Go 1.21+
Tests verify:
- EIP-712 signature recovery round-trip (signer address recoverable
from the canonical digest)
- Default USD Coin / v2 / chainId=8453 EIP-712 domain matches the
TypeScript and Python reference implementations
- Handler validation (missing signer, unsupported network)
- Solana ATA derivation determinism, TransferChecked data encoding,
ComputeBudget instruction shapes
- Requirement selection logic
Also ships a scripts/e2e binary that hits a real AceDataCloud endpoint
end-to-end using SKALE_BASE_PRIVATE_KEY.
CI: new go.yml workflow tests on Go 1.21 / 1.22 / 1.23 with race detector.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Go implementation of
@acedatacloud/x402-client/acedatacloud-x402atgo/.What's in it
EVMSigner+SignEVMPayment— EIP-3009TransferWithAuthorizationsigning for Base / SKALE via go-ethereum'sapitypes.TypedData. Signature V is normalized to 27 / 28 to match the canonical Ethereum form expected by the facilitator'secrecover.SolanaSigner+SignSolanaPayment— SPLTransferCheckedwith optionalComputeBudgetinstructions; builds the instruction, signs with a local keypair, submits via JSON-RPC, and returns the on-chain signature in the X-Payment envelope.Handler— unifiedNewHandler(HandlerOptions{...})factory withSign(ctx, accepts) (string, error)andHeaders(ctx, accepts) (map[string]string, error). Validates inputs and selects the matching requirement by network.PaymentRequirementFromMap— adapts a raw 402acceptsentry (map[string]any) into the typed struct, so users can bridge it to any HTTP-client shape.Module
github.com/AceDataCloud/X402Client/go, Go 1.21+, tag-based releases.Depends on:
github.com/ethereum/go-ethereum(EIP-712 + ECDSA)github.com/gagliardetto/solana-go(pubkey / transaction types)github.com/mr-tron/base58(base58 enc/dec)Testing
ecrecoverreturns the signer's address.USD Coin / v2 / chainId=8453match the TypeScript and Python reference.TransferCheckeddata layout,ComputeBudgetdiscriminators.accepts, errors clearly when none match.Live E2E
scripts/e2eexercises the full 402 → sign → retry flow againstapi.acedata.cloudusingSKALE_BASE_PRIVATE_KEY:Integration with the AceDataCloud Go SDK
The Go SDK PR exposes a
PaymentHandlerinterface. The README shows the trivial 4-line bridge so users can drop anx402.Handlerintoacedatacloud.NewClient.CI
New
.github/workflows/go.ymlruns Go 1.21 / 1.22 / 1.23 matrix with race detector.